function PromiseAll(promises){
    return new Promise(((resolve, reject) => {
        if(!Array.isArray(promises)){
            throw new Error('参数必须是一个数组')
        }
        let count = 0, res = []
        promises.forEach((item,index) => {
            Promise.resolve(item).then(data=> {
                if(data){
                    res[index] = data
                    count++
                    if(count === promises.length){
                        resolve(res)
                    }
                }
            }).catch(err=>{
                reject(err)
            })
        })
    }))
}
